import matplotlib.pyplot as plt

# 假设你有一系列坐标点
# track = [[-39,-30,0],[0,0,0],[1,1,79],[3,1,87],[4,2,95],[5,2,102],[7,2,111],[9,3,119],[11,3,127],[12,3,135],[13,3,143],[15,3,151],[15,4,159],[16,4,167],[17,4,175],[17,4,191],[18,4,199],[19,4,207],[19,4,223],[20,4,230],[21,4,254],[21,4,263],[22,4,271],[23,4,279],[25,4,295],[26,4,303],[27,4,310],[28,4,319],[29,4,327],[29,4,335],[31,4,351],[31,4,359],[32,4,382],[33,4,398],[34,4,423],[35,4,439],[36,4,446],[37,4,462],[37,4,471],[38,4,495],[39,4,504],[39,4,519],[41,4,527],[41,4,543],[42,4,552],[43,4,559],[44,4,567],[45,4,575],[46,4,582],[47,4,605],[49,4,615],[49,4,623],[50,4,631],[51,4,639],[52,4,719],[53,4,727],[54,4,743],[57,5,807],[58,5,815],[59,5,839],[59,5,854],[60,6,895],[61,6,910],[61,7,943],[62,7,959],[63,7,974],[63,7,1007],[64,7,1046],[65,7,1079],[65,8,1087],[66,8,1135],[67,8,1174],[67,8,1311]]
# track = [[-40,-34,0],[0,0,0],[1,0,107],[1,0,115],[2,0,124],[3,0,132],[4,0,147],[5,0,155],[5,0,163],[6,0,171],[7,0,187],[8,0,195],[9,0,203],[11,0,211],[11,0,219],[13,0,227],[14,0,235],[16,0,243],[17,0,251],[18,0,259],[19,0,267],[21,0,275],[22,0,283],[24,0,291],[26,0,299],[27,0,307],[29,0,315],[31,0,323],[33,0,331],[34,0,339],[36,0,347],[37,0,355],[40,0,363],[42,0,372],[43,0,379],[46,0,387],[47,0,395],[49,0,403],[51,0,411],[53,0,419],[54,0,427],[55,0,435],[56,0,443],[57,0,459],[57,0,467],[58,0,483],[59,0,491],[59,0,499],[61,0,507],[62,0,515],[63,0,523],[65,0,532],[66,0,539],[67,0,548],[68,0,563],[69,0,571],[70,1,600],[71,1,643],[71,1,651],[72,1,667],[73,1,675],[73,1,691],[74,1,699],[75,1,707],[75,2,715],[76,2,723],[77,2,780],[78,3,805],[79,3,830],[79,3,837],[80,3,844],[81,3,852],[82,3,876],[83,3,884],[83,4,892],[83,4,1157]]
# track = [[-34,-21,0],[0,0,0],[1,0,135],[2,0,143],[3,0,159],[3,0,295],[5,0,311],[6,0,319],[8,1,327],[9,1,335],[11,1,343],[12,1,351],[15,1,359],[17,1,367],[18,1,375],[20,1,383],[21,1,391],[24,1,399],[26,1,407],[29,1,415],[32,1,423],[34,1,431],[37,1,439],[39,1,447],[41,1,455],[44,1,463],[46,1,471],[47,1,479],[50,1,487],[51,1,495],[53,1,503],[54,1,511],[56,1,519],[57,1,527],[58,1,535],[60,1,543],[61,1,551],[63,1,559],[64,1,567],[65,1,575],[67,1,583],[68,1,591],[69,1,599],[71,1,607],[72,1,615],[73,1,623],[75,1,631],[75,1,639],[77,1,647],[77,1,655],[79,1,663],[80,1,679],[81,1,687],[81,1,695],[83,1,703],[84,1,719],[86,1,735],[87,1,751],[88,1,759],[90,2,767],[91,2,775],[92,3,791],[93,3,839],[94,3,871],[95,3,895],[96,4,903],[97,5,919],[98,5,935],[99,5,943],[99,5,951],[100,5,967],[101,5,975],[101,5,991],[103,5,1015],[104,6,1023],[105,6,1047],[106,7,1055],[107,7,1071],[107,7,1079],[108,7,1087],[109,7,1103],[109,7,1159],[110,8,1183],[111,9,1191],[111,9,1487]]
track = [[-40, -31, 0], [0, 0, 0], [1, 0, 143], [3, 0, 152], [4, 0, 160], [5, 0, 169], [6, 0, 176], [8, 0, 185],
         [13, 0, 193], [14, 0, 200], [14, 0, 208], [14, 0, 217], [14, 0, 224], [15, 0, 233], [16, 0, 240], [16, 0, 247],
         [16, 0, 255], [17, 0, 263], [19, 0, 271], [21, 0, 278], [23, 0, 286], [24, 0, 293], [26, 0, 301], [27, 0, 309],
         [29, 0, 339], [35, 0, 346], [36, 0, 353], [37, 0, 362], [39, 0, 371], [40, 0, 379], [41, 0, 388], [44, 0, 397],
         [45, 0, 405], [45, 0, 414], [45, 0, 422], [46, 0, 430], [50, 0, 437], [51, 0, 446], [57, 0, 455], [58, 0, 504],
         [59, 0, 512], [61, 0, 520], [61, 0, 555], [63, 0, 563], [63, 0, 570], [65, 0, 614], [65, 0, 622], [67, 0, 630],
         [69, 0, 637], [70, 0, 657], [71, 0, 666], [73, 0, 673], [73, 0, 681], [74, 0, 701], [74, 0, 709], [77, 0, 716],
         [77, 0, 723], [78, 0, 731], [79, 0, 738], [81, 0, 745], [83, 0, 752], [84, 0, 761], [84, 0, 768], [86, 0, 777],
         [88, 0, 785], [90, 0, 793], [92, 0, 802], [94, 0, 810], [95, 0, 817], [97, 0, 824], [97, 0, 833], [99, 0, 840],
         [100, 0, 859], [101, 0, 868], [101, 0, 875], [103, 0, 883], [104, 0, 892], [105, 1, 899], [105, 1, 908],
         [106, 1, 917], [106, 1, 926], [108, 1, 934], [108, 1, 941], [109, 1, 948], [109, 1, 957], [111, 2, 965],
         [113, 2, 974], [113, 2, 982], [113, 3, 991], [114, 3, 999], [115, 4, 1008], [116, 4, 1017], [116, 4, 1038],
         [118, 4, 1046], [119, 5, 1054], [120, 6, 1069], [120, 7, 1078], [121, 8, 1091], [122, 8, 1100], [124, 8, 1109],
         [124, 8, 1118], [126, 8, 1126], [128, 8, 1135], [128, 9, 1144], [130, 9, 1151], [131, 10, 1159],
         [131, 10, 1170], [133, 10, 1270], [134, 10, 1424], [135, 10, 1574], [135, 10, 1894]]
x = []
y = []
t = []
for i in range(len(track)):
    x.append(track[i][0])
    y.append(track[i][1])
    t.append(track[i][2])

l = []
count_x = [0, 0, 0]
count_y = [0, 0, 0]
count_t = [0, 0, 0, 0]
for i in range(1, len(track)):

    x_d = track[i][0] - track[i - 1][0]
    if x_d == 1:
        count_x[0] += 1
    elif x_d == 2:
        count_x[1] += 1
    else:
        count_x[2] += 1

    y_d = track[i][1] - track[i - 1][1]
    if y_d == 0:
        count_y[0] += 1
    elif y_d == 1:
        count_y[1] += 1
    else:
        count_y[2] += 1

    t_d = track[i][2] - track[i - 1][2]
    if 5 < t_d <= 10:
        count_t[0] += 1
    elif 10 <= t_d < 50:
        count_t[1] += 1
    elif 50 <= t_d < 100:
        count_t[2] += 1
    else:
        count_t[3] += 1
    l.append([x_d, y_d, t_d])

print("轨迹变化", l)
print("轨迹长度", len(track))
print("统计x轴出现次数：", count_x)
print("统计y轴出现次数：", count_y)
print("统计时间出现范围：", count_t)

# 使用plot函数绘制曲线
plt.plot(x, y)

# 显示图像
plt.show()
